import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:lcapp/basic/local_info.dart';
import 'package:lcapp/basic/user_info.dart';
import 'package:lcapp/config/const_config.dart';
import 'package:lcapp/widget/lc_gesture_detector.dart';

class FaxianhopPage extends StatefulWidget {
  const FaxianhopPage({Key? key}) : super(key: key);

  @override
  _FaxianhopPageState createState() => _FaxianhopPageState();
}

class _FaxianhopPageState extends State<FaxianhopPage> {
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.symmetric(vertical: 40.w,horizontal:30.w),
      alignment: Alignment.topCenter,
      child: Container(
        height: 400.w,
        decoration: BoxDecoration(
            color: Colors.white,
          borderRadius: BorderRadius.circular(20.w)
        ),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Expanded(
                  child: lcGestureDetector(
                    isLogin:true,
                    onTap: (){
                      if(userInfo.vip!=1){
                        SmartDialog.show(
                          alignment: Alignment.center,
                          clickMaskDismiss: true,
                          maskColor: Color.fromRGBO(0, 0, 0, 0.5), builder: (BuildContext context) {
                            return Container(
                              child: Column(
                                mainAxisAlignment: MainAxisAlignment.end,
                                children: [
                                  Expanded(child: Container()),
                                  Container(
                                    child: Column(
                                      children: [
                                        Container(
                                          child: Text('您还不是会员',style: TextStyle(
                                              color: Colors.black,
                                              fontSize: 35.sp,
                                              fontWeight: FontWeight.w700
                                          ),),
                                          margin: EdgeInsets.only(bottom: 20.w),
                                        ),
                                        Container(
                                          child: Text('请开通后查看',style: TextStyle(
                                              color: Color(0xff242424),
                                              fontSize: 30.sp,
                                              fontWeight: FontWeight.w500
                                          ),),
                                        ),
                                        Container(
                                          margin: EdgeInsets.symmetric(vertical: 40.w,horizontal: 0.w),
                                          height: 1,
                                          color: Colors.grey,
                                        ),
                                        GestureDetector(
                                          onTap: (){
                                            SmartDialog.dismiss();
                                            Navigator.of(context).pushNamed("MinVipPage").then((value){
                                              refreshUserInfo();
                                            });
                                          },
                                          child: Container(
                                            // padding: EdgeInsets.symmetric(horizontal: 60.w),
                                            child: Row(
                                              children: [
                                                Expanded(child: Text('开通会员',textAlign: TextAlign.left,style: TextStyle(
                                                    color: Color(0xff232323),
                                                    fontSize: 30.sp,
                                                    fontWeight: FontWeight.w600
                                                ),)),
                                                Icon(Icons.arrow_forward_ios,size: 30.sp,)
                                              ],
                                            ),
                                          ),
                                        ),
                                        GestureDetector(
                                          onTap: (){
                                            SmartDialog.dismiss();
                                          },
                                          child: Container(
                                            width: 1.sw-120.w,
                                            height: 90.w,
                                            alignment: Alignment.center,
                                            margin: EdgeInsets.only(top: 50.w),
                                            decoration: BoxDecoration(
                                                color: Color(0xffEBEBEB),
                                                borderRadius: BorderRadius.circular(10.w)
                                            ),
                                            child: Text('取消',style: TextStyle(
                                                color: Color(0xff232323),
                                                fontSize: 30.sp,
                                                fontWeight: FontWeight.w500
                                            ),),
                                          ),
                                        )
                                      ],
                                    ),
                                    decoration: BoxDecoration(
                                        color: Colors.white,
                                        borderRadius: BorderRadius.only(topLeft: Radius.circular(15.w),topRight: Radius.circular(15.w))
                                    ),
                                    padding: EdgeInsets.only(left: 60.w,right: 60.w,top: 30.w,bottom: 20.w+ScreenUtil().bottomBarHeight),
                                  )
                                ],
                              ),
                            );
                        },
                        );
                        return;
                      }
                      Navigator.of(context).pushNamed('FaxianWebviewPage',arguments: {
                        'url':'${BasVueurl}/#/shopPrice?token=${AsrLocalInfo.token}',
                        'title':'厂家报价'
                      });
                    },
                    child: Container(
                      color: Colors.transparent,
                      child: Column(
                        children: [
                          Image.asset('assets/faxian/fx_cjbj.png',height: 80.w,),
                          SizedBox(height: 40.w,),
                          Text('厂家报价',style: TextStyle(
                              color: Colors.black,
                              fontSize: 40.sp,
                              fontWeight: FontWeight.w600
                          ),),
                          SizedBox(height: 20.w,),
                          Text('每日更新深加工\n企业报价',textAlign: TextAlign.center,style: TextStyle(
                            color: Color(0xff848484),
                            fontSize: 24.sp,
                          ),)
                        ],
                        mainAxisAlignment: MainAxisAlignment.center,
                        crossAxisAlignment: CrossAxisAlignment.center,
                      ),
                    ),
                  ),
                  flex: 1,),
                Container(
                  width: 1,
                  height: 200.w,
                  color: Color(0xffE9E8E9),
                ),
                Expanded(child:lcGestureDetector(
                  isLogin:true,
                  onTap: (){
                    if(userInfo.vip!=1){
                      SmartDialog.show(
                        alignment: Alignment.center,
                        clickMaskDismiss: true,
                        maskColor: Color.fromRGBO(0, 0, 0, 0.5), builder: (BuildContext context) {
                          return Container(
                            child: Column(
                              mainAxisAlignment: MainAxisAlignment.end,
                              children: [
                                Expanded(child: Container()),
                                Container(
                                  child: Column(
                                    children: [
                                      Container(
                                        child: Text('您还不是会员',style: TextStyle(
                                            color: Colors.black,
                                            fontSize: 35.sp,
                                            fontWeight: FontWeight.w700
                                        ),),
                                        margin: EdgeInsets.only(bottom: 20.w),
                                      ),
                                      Container(
                                        child: Text('请开通后查看',style: TextStyle(
                                            color: Color(0xff242424),
                                            fontSize: 30.sp,
                                            fontWeight: FontWeight.w500
                                        ),),
                                      ),
                                      Container(
                                        margin: EdgeInsets.symmetric(vertical: 40.w,horizontal: 0.w),
                                        height: 1,
                                        color: Colors.grey,
                                      ),
                                      GestureDetector(
                                        onTap: (){
                                          SmartDialog.dismiss();
                                          Navigator.of(context).pushNamed("MinVipPage").then((value){
                                            refreshUserInfo();
                                          });
                                        },
                                        child: Container(
                                          // padding: EdgeInsets.symmetric(horizontal: 60.w),
                                          child: Row(
                                            children: [
                                              Expanded(child: Text('开通会员',textAlign: TextAlign.left,style: TextStyle(
                                                  color: Color(0xff232323),
                                                  fontSize: 30.sp,
                                                  fontWeight: FontWeight.w600
                                              ),)),
                                              Icon(Icons.arrow_forward_ios,size: 30.sp,)
                                            ],
                                          ),
                                        ),
                                      ),
                                      GestureDetector(
                                        onTap: (){
                                          SmartDialog.dismiss();
                                        },
                                        child: Container(
                                          width: 1.sw-120.w,
                                          height: 90.w,
                                          alignment: Alignment.center,
                                          margin: EdgeInsets.only(top: 50.w),
                                          decoration: BoxDecoration(
                                              color: Color(0xffEBEBEB),
                                              borderRadius: BorderRadius.circular(10.w)
                                          ),
                                          child: Text('取消',style: TextStyle(
                                              color: Color(0xff232323),
                                              fontSize: 30.sp,
                                              fontWeight: FontWeight.w500
                                          ),),
                                        ),
                                      )
                                    ],
                                  ),
                                  decoration: BoxDecoration(
                                      color: Colors.white,
                                      borderRadius: BorderRadius.only(topLeft: Radius.circular(15.w),topRight: Radius.circular(15.w))
                                  ),
                                  padding: EdgeInsets.only(left: 60.w,right: 60.w,top: 30.w,bottom: 20.w+ScreenUtil().bottomBarHeight),
                                )
                              ],
                            ),
                          );
                      },

                      );
                      return;
                    }
                    Navigator.of(context).pushNamed('FaxianWebviewPage',arguments: {
                      'url':'${BasVueurl}/#/carInfo?token=${AsrLocalInfo.token}',
                      'title':'车辆情况'
                    });
                  },
                  child:  Container(
                    color: Colors.transparent,
                    child: Column(
                      children: [
                        Image.asset('assets/faxian/fx_clqk.png',height: 80.w,),
                        SizedBox(height: 40.w,),
                        Text('车辆情况',style: TextStyle(
                            color: Colors.black,
                            fontSize: 40.sp,
                            fontWeight: FontWeight.w600
                        ),),
                        SizedBox(height: 20.w,),
                        Text('深加工\n剩余车辆信息',textAlign: TextAlign.center,style: TextStyle(
                          color: Color(0xff848484),
                          fontSize: 24.sp,
                        ),)
                      ],
                      mainAxisAlignment: MainAxisAlignment.center,
                      crossAxisAlignment: CrossAxisAlignment.center,
                    ),
                  ),
                ),flex: 1,),
              ],
            )
          ],
        ),
      ),
    );
  }
}
